#include<bits/stdc++.h>
using namespace std;

class Solution {
public:
    vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n) {
        vector<int>diff(n + 2, 0);
        for(int i = 0; i < bookings.size(); i++){
            diff[bookings[i][0]] += bookings[i][2];
            diff[bookings[i][1] + 1] -= bookings[i][2];
        }
        vector<int>ans;
        ans.push_back(diff[1]);
        for(int i = 2; i <= n; i++){
            ans.push_back(ans[i - 2] + diff[i]);
        }
        return ans;
    }
};


/**
 * 2021.8.31
 * 差分思想
 */